package service

import (
	"context"
	"fmt"

	pb "gitee.com/jiebaiyou/demo-grpc/protos/user/v2"
)

type UserServer struct {
	pb.UnimplementedUserServiceServer
}

func NewUserServer() *UserServer {
	return &UserServer{}
}

func (s *UserServer) Create(ctx context.Context, req *pb.CreateRequest) (*pb.CreateResponse, error) {
	// 这里实现创建用户逻辑
	// 例如：验证用户信息，保存用户信息等
	fmt.Println("Create request received")
	// 假设创建成功
	return &pb.CreateResponse{
		Status:  200,
		Message: "success",
	}, nil
}

func (s *UserServer) Get(ctx context.Context, req *pb.GetRequest) (*pb.GetResponse, error) {
	// 这里实现获取用户信息逻辑
	// 例如：根据用户ID查询用户信息
	fmt.Println("Get request received")
	// 假设获取成功
	return &pb.GetResponse{
		Status:  200,
		Message: "success",
		Data: &pb.UserData{
			UserId:   "1001",
			Username: "testuser",
			Password: "testpassword",
		},
	}, nil
}
